// 引入axios
import axios from "axios";
// 引入nprogress插件
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'
let requests = axios.create({
  baseURL:"/api",
  timeout: 5000
})
// 请求拦截
requests.interceptors.request.use((config)=>{
  // 开始时显示进度条
  nprogress.start();
  return config;
})
// 响应拦截
requests.interceptors.response.use(
  // 请求结束后隐藏进度条
  (res)=>{
    nprogress.done();
    return res.data;
  },
  (err)=>{
    return Promise.reject(new Error("fail"))
  });
  export default requests;